<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD><TITLE>Tcl_ExprLongObj manual page - Tcl Library Procedures</TITLE>
<link rel="stylesheet" href="../docs.css" type="text/css" media="all">
</HEAD>
<BODY><H2><a href="../contents.htm">Tcl8.6.11/Tk8.6.11 Documentation</a> <small>&gt;</small> <a href="contents.htm">Tcl C API</a> <small>&gt;</small> ExprLongObj</H2>
<H3><A HREF="../UserCmd/contents.htm">Tcl/Tk Applications</A> | <A HREF="../TclCmd/contents.htm">Tcl Commands</A> | <A HREF="../TkCmd/contents.htm">Tk Commands</A> | <A HREF="../ItclCmd/contents.htm">[incr Tcl] Package Commands</A> | <A HREF="../SqliteCmd/contents.htm">SQLite3 Package Commands</A> | <A HREF="../TdbcCmd/contents.htm">TDBC Package Commands</A> | <A HREF="../TdbcmysqlCmd/contents.htm">tdbc::mysql Package Commands</A> | <A HREF="../TdbcodbcCmd/contents.htm">tdbc::odbc Package Commands</A> | <A HREF="../TdbcpostgresCmd/contents.htm">tdbc::postgres Package Commands</A> | <A HREF="../TdbcsqliteCmd/contents.htm">tdbc::sqlite3 Package Commands</A> | <A HREF="../ThreadCmd/contents.htm">Thread Package Commands</A> | <A HREF="../TclLib/contents.htm">Tcl C API</A> | <A HREF="../TkLib/contents.htm">Tk C API</A> | <A HREF="../ItclLib/contents.htm">[incr Tcl] Package C API</A> | <A HREF="../TdbcLib/contents.htm">TDBC Package C API</A></H3>
<DL>
<DD><A HREF="ExprLongObj.htm#M2" NAME="L300">NAME</A>
<DL><DD>Tcl_ExprLongObj, Tcl_ExprDoubleObj, Tcl_ExprBooleanObj, Tcl_ExprObj &mdash; evaluate an expression</DD></DL>
<DD><A HREF="ExprLongObj.htm#M3" NAME="L301">SYNOPSIS</A>
<DL>
<DD><B>#include &lt;tcl.h&gt;</B>
<DD>int
<DD><B>Tcl_ExprLongObj</B>(<I>interp, objPtr, longPtr</I>)
<DD>int
<DD><B>Tcl_ExprDoubleObj</B>(<I>interp, objPtr, doublePtr</I>)
<DD>int
<DD><B>Tcl_ExprBooleanObj</B>(<I>interp, objPtr, booleanPtr</I>)
<DD>int
<DD><B>Tcl_ExprObj</B>(<I>interp, objPtr, resultPtrPtr</I>)
</DL>
<DD><A HREF="ExprLongObj.htm#M4" NAME="L302">ARGUMENTS</A>
<DL class="arguments">
</DL>
<DD><A HREF="ExprLongObj.htm#M5" NAME="L303">DESCRIPTION</A>
<DD><A HREF="ExprLongObj.htm#M6" NAME="L304">SEE ALSO</A>
<DD><A HREF="ExprLongObj.htm#M7" NAME="L305">KEYWORDS</A>
</DL>
<H3><A NAME="M2">NAME</A></H3>
Tcl_ExprLongObj, Tcl_ExprDoubleObj, Tcl_ExprBooleanObj, Tcl_ExprObj &mdash; evaluate an expression
<H3><A NAME="M3">SYNOPSIS</A></H3>
<B>#include &lt;tcl.h&gt;</B><BR>
int<BR>
<B>Tcl_ExprLongObj</B>(<I>interp, objPtr, longPtr</I>)<BR>
int<BR>
<B>Tcl_ExprDoubleObj</B>(<I>interp, objPtr, doublePtr</I>)<BR>
int<BR>
<B>Tcl_ExprBooleanObj</B>(<I>interp, objPtr, booleanPtr</I>)<BR>
int<BR>
<B>Tcl_ExprObj</B>(<I>interp, objPtr, resultPtrPtr</I>)<BR>
<H3><A NAME="M4">ARGUMENTS</A></H3>
<DL class="arguments">
<DT><A HREF="../TclLib/Interp.htm">Tcl_Interp</A> <B>*interp</B> (in)<DD>
Interpreter in whose context to evaluate <I>objPtr</I>.
<P><DT><A HREF="../TclLib/Object.htm">Tcl_Obj</A> <B>*objPtr</B> (in)<DD>
Pointer to a value containing the expression to evaluate.
<P><DT>long <B>*longPtr</B> (out)<DD>
Pointer to location in which to store the integer value of the
expression.
<P><DT>int <B>*doublePtr</B> (out)<DD>
Pointer to location in which to store the floating-point value of the
expression.
<P><DT>int <B>*booleanPtr</B> (out)<DD>
Pointer to location in which to store the 0/1 boolean value of the
expression.
<P><DT><A HREF="../TclLib/Object.htm">Tcl_Obj</A> <B>**resultPtrPtr</B> (out)<DD>
Pointer to location in which to store a pointer to the value
that is the result of the expression.
<P></DL>
<H3><A NAME="M5">DESCRIPTION</A></H3>
These four procedures all evaluate an expression, returning
the result in one of four different forms.
The expression is given by the <I>objPtr</I> argument, and it
can have any of the forms accepted by the <B><A HREF="../TclCmd/expr.htm">expr</A></B> command.
<P>
The <I>interp</I> argument refers to an interpreter used to
evaluate the expression (e.g. for variables and nested Tcl
commands) and to return error information.
<P>
For all of these procedures the return value is a standard
Tcl result: <B><A HREF="../TclCmd/catch.htm">TCL_OK</A></B> means the expression was successfully
evaluated, and <B><A HREF="../TclCmd/catch.htm">TCL_ERROR</A></B> means that an error occurred while
evaluating the expression.
If <B><A HREF="../TclCmd/catch.htm">TCL_ERROR</A></B> is returned,
then a message describing the error
can be retrieved using <B><A HREF="../TclLib/SetResult.htm">Tcl_GetObjResult</A></B>.
If an error occurs while executing a Tcl command embedded in
the expression then that error will be returned.
<P>
If the expression is successfully evaluated, then its value is
returned in one of four forms, depending on which procedure
is invoked.
<B>Tcl_ExprLongObj</B> stores an integer value at <I>*longPtr</I>.
If the expression's actual value is a floating-point number,
then it is truncated to an integer.
If the expression's actual value is a non-numeric string then
an error is returned.
<P>
<B>Tcl_ExprDoubleObj</B> stores a floating-point value at <I>*doublePtr</I>.
If the expression's actual value is an integer, it is converted to
floating-point.
If the expression's actual value is a non-numeric string then
an error is returned.
<P>
<B>Tcl_ExprBooleanObj</B> stores a 0/1 integer value at <I>*booleanPtr</I>.
If the expression's actual value is an integer or floating-point
number, then they store 0 at <I>*booleanPtr</I> if
the value was zero and 1 otherwise.
If the expression's actual value is a non-numeric string then
it must be one of the values accepted by <B><A HREF="../TclLib/GetInt.htm">Tcl_GetBoolean</A></B>
such as
&ldquo;yes&rdquo;
or
&ldquo;no&rdquo;,
or else an error occurs.
<P>
If <B>Tcl_ExprObj</B> successfully evaluates the expression,
it stores a pointer to the Tcl value
containing the expression's value at <I>*resultPtrPtr</I>.
In this case, the caller is responsible for calling
<B><A HREF="../TclLib/Object.htm">Tcl_DecrRefCount</A></B> to decrement the value's reference count
when it is finished with the value.

<H3><A NAME="M6">SEE ALSO</A></H3>
<B><A HREF="../TclLib/ExprLong.htm">Tcl_ExprLong</A></B>, <B><A HREF="../TclLib/ExprLong.htm">Tcl_ExprDouble</A></B>, <B><A HREF="../TclLib/ExprLong.htm">Tcl_ExprBoolean</A></B>, <B><A HREF="../TclLib/ExprLong.htm">Tcl_ExprString</A></B>, <B><A HREF="../TclLib/SetResult.htm">Tcl_GetObjResult</A></B>
<H3><A NAME="M7">KEYWORDS</A></H3>
<A href="../Keywords/B.htm#boolean">boolean</A>, <A href="../Keywords/D.htm#double">double</A>, <A href="../Keywords/E.htm#evaluate">evaluate</A>, <A href="../Keywords/E.htm#expression">expression</A>, <A href="../Keywords/I.htm#integer">integer</A>, <A href="../Keywords/V.htm#value">value</A>, <A href="../Keywords/S.htm#string">string</A>
<div class="copy">Copyright &copy; 1996-1997 Sun Microsystems, Inc.
</div>
</BODY></HTML>
